home *** CD-ROM | disk | FTP | other *** search
/ Risc World 3 / Risc World 3.iso / SOFTWARE / ISSUE6 / PD / PDF / DrawFile / h / DrawFileVisitor < prev    next >
Text File  |  2003-02-14  |  5KB  |  147 lines

  1. //--------------------------------------------------------------------------
  2. //
  3. //   Copyright (c) 2002, Colin Granville
  4. //
  5. //   All rights reserved.
  6. //
  7. //   Redistribution and use in source and binary forms, with or
  8. //   without modification, are permitted provided that the following 
  9. //   conditions are met:
  10. //
  11. //      * Redistributions of source code must retain the above copyright 
  12. //        notice, this list of conditions and the following disclaimer.
  13. //
  14. //      * Redistributions in binary form must reproduce the above 
  15. //        copyright notice, this list of conditions and the following 
  16. //        disclaimer in the documentation and/or other materials 
  17. //        provided with the distribution.
  18. //
  19. //      * The name Colin Granville may not be used to endorse or promote 
  20. //        products derived from this software without specific prior 
  21. //        written permission.
  22. //
  23. //   THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 
  24. //   "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 
  25. //   LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS 
  26. //   FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE 
  27. //   COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 
  28. //   INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 
  29. //   (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR 
  30. //   SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
  31. //   HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, 
  32. //   STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) 
  33. //   ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED 
  34. //   OF THE POSSIBILITY OF SUCH DAMAGE.
  35. //
  36. //--------------------------------------------------------------------------
  37.  
  38. #ifndef DrawFileVisitor_h
  39. #define DrawFileVisitor_h
  40.  
  41. #include "GuiBBox.h"
  42. #include <stdlib.h>
  43.  
  44. class DrawFileVisitor
  45.  
  46.   public:
  47.     virtual int fileHeader(size_t start)                      {return start==start;}
  48.     virtual int textObject(size_t start)                      {return start==start;}
  49.     virtual int transformedTextObject(size_t start)           {return start==start;}
  50.     virtual int pathObject(size_t start)                      {return start==start;}
  51.     virtual int spriteObject(size_t start)                    {return start==start;}
  52.     virtual int transformedSpriteObject(size_t start)         {return start==start;}
  53.     virtual int enteringGroupObject(size_t start)             {return start==start;}
  54.     virtual int leavingGroupObject(size_t start)              {return start==start;}
  55.     virtual int taggedObject(size_t start)                    {return start==start;}
  56.     virtual int fontTable(size_t start)                       {return start==start;}
  57.     virtual int textAreaObject(size_t start)                  {return start==start;}
  58.     virtual int textColumnObject(size_t start)                {return start==start;}
  59.     virtual int optionsObject(size_t start)                   {return start==start;}
  60.     virtual int unknownObject(size_t start)                   {return start==start;}
  61.  
  62. // structures
  63.     class FileHeader
  64.     {
  65.       public:
  66.         char    formatId[4];
  67.         int     majorFormatVersion;
  68.         int     minorFormatVersion;
  69.         char    programId[12];
  70.         GuiBBox bounds;
  71.     };
  72.  
  73.     class Transform
  74.     {
  75.        public:
  76.        int m0,m1;
  77.        int m2,m3;
  78.        int m4,m5;
  79.     };
  80.  
  81.     class ObjectHeader
  82.     { 
  83.       public:     
  84.         unsigned int objectType;
  85.         size_t size;
  86.     };
  87.  
  88.     class BoundedObjectHeader : public ObjectHeader
  89.     {
  90.       public:
  91.          GuiBBox bounds;
  92.     };
  93.  
  94.     class GroupObject : public BoundedObjectHeader
  95.     {
  96.       public:
  97.         char name[12];
  98.     };
  99.  
  100.     class FontTable : public ObjectHeader
  101.     {
  102.     };
  103.  
  104.     class TransformedTextObject : public BoundedObjectHeader
  105.     {
  106.       public:
  107.         Transform matrix;
  108.         enum {KERN = (1<<0),RIGHT_TO_LEFT=(1<<1)};
  109.         int           flags;
  110.         unsigned int  foreColour;
  111.         unsigned int  backColour;
  112.         int           font; //as passed to GuiDrawFileFonts
  113.         size_t        fontXSize;
  114.         size_t        fontYSize;
  115.         int           x;
  116.         int           y;
  117.         char*         getText()  {return sizeof(TransformedTextObject)+(char*)this;}
  118.     };
  119.  
  120.     class PathObject : public BoundedObjectHeader
  121.     {
  122.       public:
  123.         unsigned int  fillColour;
  124.         unsigned int  outlineColour;
  125.         size_t        outlineWidth;
  126.         unsigned char pathStyle;
  127.         unsigned char reserved;
  128.         unsigned char capWidth;
  129.         unsigned char capHeight;
  130.         bool hasDash()        {return pathStyle & (1<<7);}
  131.         int& value(int n)     {return ((int*)(sizeof(PathObject)+(char*)this))[n];}
  132.         int* dashStart()      {return hasDash()? &value(0):0;}
  133.         int* pathStart()      {return hasDash()? &value(0)+2+value(1):&value(0);}
  134.     };
  135.  
  136.     class TransformedSpriteObject : public BoundedObjectHeader
  137.     {
  138.       public:
  139.         Transform matrix;
  140.         char* getSprite()   {return sizeof(TransformedSpriteObject)+(char*)this;}
  141.     };
  142. };
  143.  
  144.  
  145. #endif
  146.